package Demo5;

import java.io.FileWriter;
import java.io.IOException;
import java.util.Random;

public class GenerateRandomLetters extends Thread{
    private static final Object lock = new Object();

    @Override
    public void run() {
        synchronized (lock) {
            for (char c = 'a'; c <= 'e'; c++) {
                for (int i = 1; i <= 10000; i++) {
                    try (FileWriter writer = new FileWriter("D:/text/" + c + "/" + c + i + ".txt")) {
                        Random random = new Random();
                        for (int j = 0; j < 10; j++) {
                            char randomChar = (char) (random.nextInt(26) + 'a');
                            writer.write(randomChar);
                        }
                    } catch (IOException e) {
                        e.printStackTrace();
                    }
                }
            }
        }
    }
}
